package com.example.service.impl;

import com.example.entity.Employee;
import com.example.entity.example.EmployeeExample;
import com.example.mapper.EmployeeMapper;
import com.example.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired(required = false)
    EmployeeMapper employeeMapper;

    @Override
    public List<Employee> getByExampleWithLimit(EmployeeExample example, Integer curPage, Integer pageSize) {
        int begin = (curPage - 1) * pageSize;
        return employeeMapper.selectByExampleWithLimit(example, begin, pageSize);
    }

    @Override
    public long getCountByExample(EmployeeExample example) {
        return employeeMapper.countByExample(example);
    }

    @Override
    public void addEmployee(Employee job) {
        employeeMapper.insert(job);
    }

    @Override
    public void removeById(Integer id) {
        employeeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateSelectiveById(Employee employee) {
        employeeMapper.updateByPrimaryKeySelective(employee);
    }

    @Override
    public Employee getById(Integer id) {
        return employeeMapper.selectByPrimaryKey(id);
    }
}
